package com.luhuiguo.gwt.mvp.dispatcher.client.gin;

import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.luhuiguo.gwt.mvp.dispatcher.client.DefaultExceptionHandler;
import com.luhuiguo.gwt.mvp.dispatcher.client.DispatcherAsync;
import com.luhuiguo.gwt.mvp.dispatcher.client.ExceptionHandler;
import com.luhuiguo.gwt.mvp.dispatcher.client.SecuredMvpDispatcherAsync;
import com.luhuiguo.gwt.mvp.presenter.client.DefaultEventBus;
import com.luhuiguo.gwt.mvp.presenter.client.EventBus;

public class SecuredMvpDispatcherModule extends AbstractDispatcherModule {

    protected final Class<? extends EventBus> eventBusType;

    @Override
    protected void configure() {
        super.configure();
        //bind(ExceptionHandler.class).to(exceptionHandlerType);
        bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
    }

    public SecuredMvpDispatcherModule() {
        this(DefaultExceptionHandler.class, DefaultEventBus.class);
    }

    public SecuredMvpDispatcherModule(Class<? extends ExceptionHandler> exceptionHandlerType,
            Class<? extends EventBus> eventBusType) {
        super(exceptionHandlerType);
        this.eventBusType = eventBusType;

    }

    @Provides
    @Singleton
    protected DispatcherAsync provideDispatcherAsync(ExceptionHandler exceptionHandler, EventBus eventBus) {
        return new SecuredMvpDispatcherAsync(exceptionHandler, eventBus);
    }

}
